<?php if ( ! defined('ABSPATH')) exit('restricted access'); //stop direct script access

/**
 * Class for Wordpress Shortcodes
 * @package WordPress
 * @subpackage WelCare
 * @author	WP Nukes Developers Team (Allan)
 * @link	http://www.wpnukes.com
 * @since	Version 1.0
 */

class FW_Shortcodes
{
	private $_webnukes = array();
	var $_codes = array();
	
	function __construct()
	{
		$this->_webnukes = & $GLOBALS['_webnukes'];
	}
	
	/** Add the shortcodes by including shorcodes_array.php */
	function add_shortcode()
	{
		global $options;
		$options = array();
		get_template_part('libs/shortcodes_array');

		foreach($options as $k=>$v)
		{
			add_shortcode('FW_'.$k, array($this, $k));
		}
	}
	
	/**
	 * returns the doctor search form
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	 
	function doctor_form($atts, $content = null)
	{
		global $wpnukes;
		
		extract( shortcode_atts( array( 'page_id' => ''), $atts ) );
		
		$url = ( ! $page_id) ? $this->_webnukes->get_settings('general_settings', 'doctor_listing_page') : $page_id;

		if(is_a($wpnukes, 'wpnukes_doctors'))
		{
			return $wpnukes->search_form('doctors/theme_doctor_form', $url);
		}else
		{
			$wpnukes = new wpnukes_doctors;
			return $wpnukes->search_form('doctors/theme_doctor_form', $url);
		}
	}
	
	/**
	 * returns the appointment request form
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	 
	function appointment_form($atts, $content = null)
	{
		global $wpnukes;
		
		extract( shortcode_atts( array('last' => ''), $atts ) );
		
		if(is_a($wpnukes, 'wpnukes_doctors'))
		{
			return $wpnukes->app_form('doctors/theme_appointment_form', true);
		}else
		{
			$wpnukes = new wpnukes_doctors;
			return $wpnukes->app_form('doctors/theme_appointment_form', true);
		}
	}

	function advanced_search($atts, $content = null)
	{
		extract( shortcode_atts( array( 'last' => ''), $atts ) );
		$output = '';
		
		ob_start();
		include(get_template_directory().'/libs/advanced_search.php');
		$output = ob_get_contents();
		ob_end_clean();
		
		return $output;
	}
	
	/**
	 * returns the contact us form
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function contact_form($atts, $content = null)
	{		
		extract( shortcode_atts( array( 'last' => ''), $atts ) );
		
		ob_start();
		include_once(get_template_directory().'/libs/contact_form.php');
		$contents = ob_get_contents();
		ob_end_clean();
		
		return $contents;
		
	}
	
	/**
	 * returns the toggler
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function toggle($atts, $content = null)
	{
		extract( shortcode_atts( array( 'title' => '', 'show'=>false), $atts ) );
		$display = ($show) ? 'block_display' : '';
		$out = '<div class="block"><div class="heading">' .$title .'<a class="expand" href="#"></a></div>';
		$out .= '<div class="biodata-text-more '.$display.'">' .do_shortcode( $content ) .'</div></div>';
		return $out;
	}
	
	/**
	 * returns the message box
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function msg_box($atts, $content = null) {
		extract( shortcode_atts( array( 'type' => 'success', 'title'=>''), $atts ) );
		
		return '<div class="box">
					<img src="' .THEME_URL .'/images/'.$type.'.png" alt="success">
					<strong>'.$title.'</strong>
					'.do_shortcode( $content ) .'
				</div>';
	}
	
	/**
	 * returns the message box
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function testimonial($atts, $content) {
		extract( shortcode_atts( array(
			'heading' => '',
			'title' => '',
			'commenter' => '',
			'image' => '',
			'issue' => ''
		), $atts ) );

		$out = '<div class="block">';
		$out .= '<div class="heading">' .$heading .'</div>';
		$out .= '<div class="comment">';
		$out .= '<h3>' .$title .'</h3>';
		$out .= '<blockquote><span>' .$content .'</span></blockquote>';
		$out .= '<span class="tip"></span></div>';
		$out .= '<div class="comment_snap"><img src="' .$image .'" alt="" /></div>';
		$out .= '<ul class="patient">';
		$out .= '<li><strong>' .$issue .'</strong></li>';
		$out .= '<li><span class="user_icon">Patient: </span> <span class="blue_text">' .$commenter .'</span></li>';
		$out .= '</ul></div>';

		return $out;
	}
	
	/**
	 * returns list of videos from custom videos post type
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function video_posts( $atts, $content = null ) {
		extract( shortcode_atts( array(
			'title' => '',
			'posts' => 3,
			'order' => 'latest',
			'offset' => 0
		), $atts ) );
		if ($order == 'latest') {
			$order = '&order=DESC';
		} elseif ($order == 'oldest') {
			$order = '&order=ASC';
		} else {
			$order = '&orderby=rand';
		}
		$off = '';
		if ($offset != 0) { $off = '&offset=' .$offset; }
		
		$out = '';
		/** query for blog posts */
		query_posts('post_type=video&caller_get_posts=1&posts_per_page=' .$posts .$order .$off);
		/** start our loop */
		if (have_posts()) :
			$out .= '<div class="block">';
			$out .= '<div class="heading">' .$title .'</div>';
			$out .= '<div class="blog">';
			
			while (have_posts()) : the_post();

				/** get permalink */
				$permalink = get_permalink();
				/** get post title */
				$title = get_the_title();
				/** get excerpt */
				$excerpt = get_the_excerpt();
				/** get video post meta */
				$video = get_post_meta(get_the_ID(), 'video_post_meta', true);
				$video_from = $video[0]['from'];
				$video_id = $video[0]['video_id'];

				if ($video_from == 'youtube') {
					$image = 'http://i.ytimg.com/vi/' .$video_id .'/1.jpg';
				} elseif ($video_from == 'vimeo') {
					$image = vm_video_image($video_id);
				}

				$out .= '<div class="post"><div class="image">';
				$out .= '<img src="' .$image .'" alt="" />';
				$out .= '</div><div class="matter"><h3><a href="' .$permalink .'">' .$title .'</a></h3>';
				$out .= '<p>' .substr($excerpt, 0, -5) .' <a href="' .$permalink .'" class="read_more">Read More</a></p>';
				$out .= '</div></div>';
			endwhile;
			$out .= '</div></div>';
		endif;
		/** reset our query */
		wp_reset_query();
		return $out;
	}
	
	
	/**
	 * returns the insurance companies slider
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function insurance_slider( $atts, $content ) { // need to re-code
		extract( shortcode_atts( array(
			'title' => ''
		), $atts ) );
		
		ob_start();
		include_once('insurance.php');
		$out = ob_get_contents();
		ob_end_clean();
	
		return $out;
	}
	
	/**
	 * returns a HTML of styled image
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function image( $atts, $content = null ) {
		extract( shortcode_atts( array(
			'src' => '',
			'title' => '',
			'link' => ''
		), $atts ) );

		$out = '<img src="' .$src .'" alt="'.$title.'" />';

		if ($link) $out .= ' <a href="' .$link .'">'.$out.'</a>';
		
		return '<div class="image">'.$out.'</div>';
	}
	
	/**
	 * returns a list of blog posts
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function blog_posts( $atts, $content = null ) {
		extract( shortcode_atts( array(
			'title' => '',
			'posts' => 3,
			'order' => 'Latest',
			'style' => '1',
			'offset' => 0
		), $atts ) );

		if ($order == 'Latest') {
			$order = '&order=DESC';
		} elseif ($order == 'Oldest') {
			$order = '&order=ASC';
		} else {
			$order = '&orderby=rand';
		}
		$off = '';
		if ($offset != 0) { $off = '&offset=' .$offset; }
		/** query for blog posts */
		query_posts('caller_get_posts=1&posts_per_page=' .$posts .$order .$off);
		/** start our loop */
		if (have_posts()) :
			$i = 0;
			$out = '';
			if ($title && $posts > 1) $out .= '<h3 class="heading">' .$title .'</h3>';
			while (have_posts()) : the_post();
				$i++;
				$out .= '<div class="block">';
				if ($title && $i == 1 && $posts == 1) $out .= '<div class="heading">' .$title .'</div>';
			
				$image_id = get_post_thumbnail_id();
				$image = wp_get_attachment_image_src($image_id, 'post-image3');

				/** get_comments_number returns only a numeric value */
				$num_comments = get_comments_number();
				if ( comments_open() ) {
					if ( $num_comments == 0 ) {
						$comments = __('0 Comments', THEME_NAME);
					} elseif ( $num_comments > 1 ) {
						$comments = $num_comments .__(' Comments', THEME_NAME);
					} else {
						$comments = __('1 Comment', THEME_NAME);
					}
					$write_comments = '<a href="' .get_comments_link() .'">' .$comments .'</a>';
				} else {
					$write_comments = __('Comments Off.', THEME_NAME);
				}

				/** get categories */
				$categories = get_the_category();
				$separator = ', ';
				$output = '';
				if($categories){
					foreach($categories as $category) {
						$output .= '<a href="'.get_category_link($category->term_id ).'" title="' .esc_attr( sprintf( __( "View all posts in %s", THEME_NAME ), $category->name ) ) . '">' .$category->cat_name .'</a>' .$separator;
					}
					$cat = trim($output, $separator);
				}

				/** get permalink */
				$permalink = get_permalink();
				/** get post title */
				$title = get_the_title();		
				/** get excerpt */
				$excerpt = get_the_excerpt();
				switch ($style) {
					/** style 1 */
					case '1':
						$out .= '<div class="blog"><div class="image">';
						$out .= '<a href="' .$permalink .'"><img src="' .$image[0] .'" alt="" /></a>';
						$out .= '<div class="image_hover"><h3>' .$title .'</h3>';
						$out .= '<div class="post_info"><span class="">' .get_the_time('F d, Y') .'</span>|<span class="comment_icon">' .$write_comments .'</span></div></div></div>';
						$out .= '<div class="post"><div class="matter">';
						$out .= '<h3><a href="' .$permalink .'">' .$title .'</a></h3>';
						$out .= '<p>' .substr($excerpt, 0, 200) .'</p></div></div></div></div>';
					break;
					
					/** style 2 */
					case '2':
						$out .= '<div class="news"><div class="image">';
						$out .= '<a href="' .$permalink .'"><img src="' .$image[0] .'" alt="" /></a>';
						$out .= '<div class="image_hover"><h3>' .$title .'</h3>';
						$out .= '<div class="post_info"><span class="">' .get_the_time('F d, Y') .'</span>|<span class="comment_icon">' .$write_comments .'</span></div></div></div>';
						$out .= '<div class="post"><div class="matter">';
						$out .= '<h3><a href="' .$permalink .'">' .$title .'</a></h3>';
						$out .= '<div class="post_info"><span class="grey_text">' .get_the_time('F d, Y') .'</span>|<span class="grey_text">' .$write_comments .'</span></div>';
						$out .= '<p>' .substr($excerpt, 0, 150) .'</p></div></div></div></div>';
					break;

					/** style 3 */
					case '3':
						$out .= '<div class="events"><div class="image">';
						$out .= '<a href="' .$permalink .'"><img src="' .$image[0] .'" alt="" /></a>';
						$out .= '<div class="image_hover"><h3>' .$title .'</h3>';
						$out .= '<div class="post_info"><span class="">' .get_the_time('F d, Y') .'</span>|<span class="comment_icon">' .$write_comments .'</span></div></div></div>';
						$out .= '<div class="post"><h3><a href="' .$permalink .'">' .$title .'</a></h3>';
						$out .= '<ul class="event_info">';
						$out .= '<li><span class="tag">' .$cat .'</span></li>';
						$out .= '<li><span class="calendar">' .get_the_time('F d, Y') .'</span></li></ul>';
						$out .= '<p class="venudesc">' .substr($excerpt, 0, 150) .' <a href="' .$permalink .'" class="read_more">' .__('Read More', THEME_NAME) .'</a></p></div></div></div>';
					break;
				}
			endwhile;
		endif;

		/** reset our query */
		wp_reset_query();
		return $out;
	}
	
	/**
	 * returns a block that auto adjust with the parent container width
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function block($atts, $content = null) {
		extract( shortcode_atts( array(
			'type'=>'single_column',
			'last' => ''
		), $atts ) );
		
		$last_child = '';
		if (isset($last) && $last) $last_child = ' last-child';
		
		return '<div class="'.$type.'' .$last .'">' .do_shortcode( $content ) .'</div>';
	}
	
	/**
	 * returns a block that auto adjust with the parent container width
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function blockquote($atts, $content = null)
	{
		$out = '<div class="comment"><blockquote><span>';
		$out .= do_shortcode( $content );
		$out .= '</span></blockquote></div>';
		return $out;
	}
	
	/**
	 * returns an icon wrapped in a tag user specify
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function icons($atts, $content = null)
	{
		extract( shortcode_atts( array(
			'type'=>'facebook',
			'item'=>'',
			'wrap'=>'span'
		), $atts ) );

		return '<'.$wrap.' class="'.$type.' '.$item.'"></'.$wrap.'>';
	}
	
	/**
	 * returns wrapped content in a heading tag
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function heading($atts, $content = null) {
		extract( shortcode_atts( array(
			'type'=>'1',
		), $atts ) );
		
		return '<h'.$type.'>'.do_shortcode($content).'</h'.$type.'>';
	}
	
	/**
	 * returns round box html
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function round_box($atts, $content = null) {
		extract( shortcode_atts( array(
			'h' => '30',
			'w' => '70',
			'color' => '#01488E'
		), $atts ) );
		
		return '<div class="color_box2" style="background-color:'.$color.';height:'.$h.'px;width: '.$w.'px;"></div>';
	}
	
	/**
	 * returns square box html
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function square_box($atts, $content = null) {
		extract( shortcode_atts( array(
			'h' => '38',
			'w' => '38',
			'color' => '#01488E'
		), $atts ) );
		
		return '<div><span style="background-color:'.$color.';height:'.$h.'px;width: '.$w.'px;"></span>'.$content.'</div>';
	}
	
	/**
	 * returns an HTML of symptom checker
	 * @param	array	$atts		An array of attributes passes to shortcode
	 * @param	string	$content	Content that is wrapped within shortcode.
	 */
	function symptom_checker($atts, $content = null)
	{
		global $_webnukes;
		
		$is_shortcode = true;
		if( ! $wpnukes_symptoms = $_webnukes->get_settings('symptom_checker')) return;
		
		extract( shortcode_atts( array( ), $atts ) );

		ob_start();
		include_once(get_template_directory().'/symptoms_checker/steps.php');
		$output = ob_get_contents();
		ob_end_clean();
		
		return $output;
	}


	function services_slider($atts, $content = null) {
		extract( shortcode_atts( array(
			'num' => '',
			'sort' => ''
		), $atts ) );
		
		$output = "" ;
		
		$args = array('post_type'=>'service', 'showposts'=>$num, 'orderby'=>$sort) ;
		$Posts = get_posts($args);//printr($Posts);
		$posts_chunks = array_chunk( $Posts, 3 );
		$output.= '
		<section>
			<div class="services carousel2">
				<ul class="slides">';
		foreach($posts_chunks as $chunk):
		$output .= '
					<li>';
		foreach($chunk as $chunk_post) :
		
		$output .='
						<div class="service-block">
							<span><i class="fa fa-medkit"></i></span>
							<h3>'.$chunk_post->post_title.'</h3>
							<p>'.$chunk_post->post_content.'</p>
						</div>'; 
		
		endforeach; 
		
		$output.='
					</li>';
		endforeach ;
		$output.='
				</ul>
			</div>
		</section>' ;
		
	$output.= '<script>
				$(window).load(function(){
				  $(\'.carousel2\').flexslider({
					animation: "fade",
					animationLoop: true,
					controlNav: true,	
					maxItems: 3,
					minItems:1,
					pausePlay: false,
					start: function(slider){
					  $(\'body\').removeClass(\'loading\');
					}
				  });
				  
				});
				</script>' ;
				
	return $output ; 
		
	}
	
	function appointment_slidedown($atts, $content = null) {
		extract( shortcode_atts( array(
			'text' => ''
		), $atts ) );
		
		$output = "" ;
		
		$output .= '
		<section>
			<div class="app-banner">
				<p>'.$text.'</p>
				<a class="appointment-toggle" title="">'.__("MAKE AN APPOINTMENT" , THEME_NAME ).'</a>
				<form name="appointment_form" id="appointment_form" style="display:none;">
					<div class="appointment-form">
						<input name="ap_name" type="text" onblur="if(this.value=="")this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value="";" value="'.__("Name" , THEME_NAME).'" />
						<div class="double-fields">
							<input name="ap_phone" class="half" type="text" onblur="if(this.value=="")this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value="";" value="'.__("Ph No" , THEME_NAME).'" />
							<input name="ap_dr_name" class="half" type="text" onblur="if(this.value=="")this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value="";" value="'.__("Dr. Name" , THEME_NAME).'" />
						</div>
						<div class="double-fields">
							<input name="ap_time" class="half" type="text" onblur="if(this.value=="")this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value="";" value="'.__("Time" , THEME_NAME).'" />
							<input name="ap_time" class="half" type="text" onblur="if(this.value=="")this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value="";" value="'.__("Date" , THEME_NAME).'" />
						</div>
						<input name="ap_email" type="email" onblur="if(this.value=="")this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value="";" value="'.__("Email ID" , THEME_NAME).'" />
						<input name="ap_additional_info" type="text" onblur="if(this.value=="")this.value=this.defaultValue;" onfocus="if(this.value==this.defaultValue)this.value="";" value="'.__("Additional Info" , THEME_NAME).'" />
					</div>
					<span class="button-area">
						<input type="submit" value="'.__("Submit Your Appointment" , THEME_NAME).'" />
					</span>
				</form>
			</div>
		</section>' ;
		return $output ;
	}
	
	function our_blog_slider($atts, $content = null) {
		extract( shortcode_atts( array(
			'num' => '',
			'sort' => '',

		), $atts ) );
		
		$output = "" ;
		
		$args = array('post_type'=>'post', 'showposts'=>$num, 'orderby'=>$sort) ;
		$Posts = get_posts($args);//printr($Posts);
		$posts_chunks = array_chunk( $Posts, 2 );
		$output.= '
		<div class="blog-posts">
			<div class="sec-title">
				<h1>'.__("OUR" , THEME_NAME).' <span> '.__("Blog" , THEME_NAME).'</span></h1>
			</div>
			<div class="carousel">
				<ul class="slides">' ;
		foreach($posts_chunks as $chunk):
		$output.= '<li>';
		foreach($chunk as $chunk_post) :
		$terms = wp_get_post_terms( $chunk_post->ID);
		$output.='<div class="post">
					<div class="post-img">
						'.get_the_post_thumbnail($chunk_post->ID , '308x210').'
						<h3>'.$chunk_post->post_title.'</h3>
					</div>
					<span><i class="fa fa-sign-in"></i>'.__("Posted in:" , THEME_NAME);
					$count = 1 ;
					foreach($terms as $term):
		$output.=' <a href="'.get_term_link($term).'" title="">'.$term->name.'</a> /';
		
				    if($count == 2) break ;
					$count++ ;
					endforeach ;
		$output.='</span>
					<p>'.$chunk_post->post_content.'</p>
				</div>' ;
		endforeach ;	
		$output.= '</li>'; 
		endforeach ;
		$output.='
				</ul>
			</div>
		</div><script>
$(window).load(function(){
 
  $(\'.carousel\').flexslider({
	animation: "slide",
	animationLoop: true,
	controlNav: false,	
    maxItems: 3,
	minItems:1,
	pausePlay: false,
	start: function(slider){
	  $(\'body\').removeClass(\'loading\');
	}
  });  
});
/*** Document Ready Function ***/
</script>' ;
				
		return $output ;
		
	}
	
	
	function upcoming_events($atts, $content = null) {
		extract( shortcode_atts( array(
			'num' => '',
			'sort' => '',

		), $atts ) );
		
		$output = "" ;
		
		$args = array('post_type'=>'event', 'showposts'=>$num, 'orderby'=>$sort) ;
		$Posts = get_posts($args);//printr($Posts);
		$output= '' ;
		
		$output.= '<div class="upcoming-events">
						<div class="sec-title">
							<h1>'.__("Upcoming" ,THEME_NAME).' <span>'.__("Events" , THEME_NAME).'</span></h1>
						</div>			
						<div class="all-events">
							<div class="event">
								<h3><a href="'.get_permalink(kvalue($Posts , 'ID')).'" title="">'.get_the_title(kvalue($Posts , 'ID')).'</a></h3>
								<span><i class="fa fa-map-marker"></i>New York City</span>
								<span><i class="fa fa-clock-o"></i>5pm - 6pm</span>
								<p>Lorem ipsum dolor sit amet, consectetur adipisc.....</p>
							</div>
						</div>
					</div>' ;
		return $output ;
	}
	
	function our_experts_slider($atts, $content = null) {
		extract( shortcode_atts( array(
			'num' => '',
			'sort' => ''
		), $atts ) );
		
		$output = "" ;
		$args = array('post_type'=>'team', 'showposts'=>$num, 'orderby'=>$sort) ;
		$Posts = get_posts($args);//printr($Posts);
		$posts_chunks = array_chunk( $Posts, 3 );
		
		
		$output.='<section>
		<div class="sec-title">
			<h1>'.__("OUR" , THEME_NAME).' <span>'.__("EXPERTS" , THEME_NAME).'</span></h1>
		</div>
		<div class="carousel">
			<ul class="slides">';
			foreach($posts_chunks as $chunk):
			$output.='<li>';
			foreach($chunk as $p_chunk):
			$output.='
					<div class="expert">
						'.get_the_post_thumbnail($chunk_post->ID , '308x172').'
						<div class="expert-detail">
							<h2>'.kvalue($p_chunk , 'post_title').'<span>'.kvalue($post_meta , 'designation').'</span></h2>
							<p>'.kvalue($p_chunk , 'post_content').'</p>
						</div>
					</div>';
			endforeach;
			
			$output.='</li>';
			
			endforeach ; 
			
			$output.='</ul>
					</div>
				</section>
				<script type="text/javascript">
				jQuery(document).ready(function($){
					 $(\'.carousel\').flexslider({
						animation: "slide",
						animationLoop: true,
						controlNav: false,	
						maxItems: 3,
						minItems:1,
						pausePlay: false,
						start: function(slider){
						  $(\'body\').removeClass(\'loading\');
						}
  					});
					
					});
				</script>
				' ;
		
		return $output ; 
		
	}
	
	function insurance_companies_slider($atts, $content = null) {
		extract( shortcode_atts( array(
			'num' => ''
		), $atts ) );
		global $_webnukes;
		$output = "" ;
		
		$module_settings = $_webnukes->get_settings('sub_insurance_companies');
		//print_r($companies); exit ;
		//$companies_chunks = array_chunk( $Posts, 3 );
		
		$output.='<section><div class="sec-title"><h1>'.__("INSURANCE" , THEME_NAME).' <span>'.__("COMPANIES" , THEME_NAME).'</span></h1></div>
				<div id="insurance-companies" class="carousel"><ul class="slides">';
		$count = 0 ; 
		foreach(kvalue($module_settings , 'DYNAMIC') as $company):
		
		$output.= ($count == 0) ? '<li>' : '' ; 
		
		$output.='<div class="company first" style="float: left;">
					<div><a href="'.kvalue($company , 'link').'" target="'.kvalue($company , 'target').'"><img alt="" src="'.kvalue($company , 'image').'"></a></div>
				</div>';
		$count = ($count < 6) ? $count++ : 0 ;
		$output.= ($count ==6)? '</li>' : '' ;
		endforeach;
		$output.='</ul></div></section>
		<script type="text/javascript">
		jQuery(document).ready(function($){
			 $(\'.carousel\').flexslider({
				animation: "slide",
				animationLoop: true,
				controlNav: false,	
				maxItems: 3,
				minItems:1,
				pausePlay: false,
				start: function(slider){
				  $(\'body\').removeClass(\'loading\');
				}
			  });
			});
		</script>
		' ;
		return $output ; 
		
	}
	
	function services($atts, $content = null) {
		extract( shortcode_atts( array(
			'num' => '',
			'sort' => '',

		), $atts ) );
		
		$output = "" ;
		
		$args = array('post_type'=>'service', 'showposts'=>$num, 'orderby'=>$sort) ;
		$Posts = get_posts($args);//printr($Posts);
		$output= '' ;
		
		$output.= '<div class="services">';
		foreach($Posts as $p):
		
		$output.'<div class="service-block">
					<span><i class="fa fa-user-md"></i></span>
					<h3>'.kvalue($p , 'post_title').'</h3>
					<p>'.kvalue($p , 'post_title').'</p>
				</div>'; 
				
		endforeach ;
		$output.='</div>' ;
		return $output ;
	}
	
	
	
}?>